petitcomputerfandomcom-20200214-history
Petit Tutorials - PRINT and INPUT
Hello! I'm CKlidify, and in this tutorial I will teach you how to use the PRINT and INPUT commands! PRINT When using the PRINT command, you must make it look something like this PRINT "" Now, inside of those quotation marks you can write ANYTHING that you want! Such as: PRINT "I love CKlidify!" Now, if we get out of edit mode and type RUN into the console, you should see something like this: PetitComputer ver2.2 SMILEBASIC 1048576 bytes free ©2011-2012 SmileBoom Co.Ltd. READY RUN I love CKlidify! OK Now you can ignore the PetitComputer ver2.2 SMILEBASIC 1048576 bytes free ©2011-2012 SmileBoom Co.Ltd. in the console everytime! It's just talking about copyright, SMILEBASIC, how many bytes free, blah blah blah! INPUT When using the INPUT command, you must make it look something like this INPUT "";VAR$ Now, what this does. Is prints whatever you type in the quotation marks, then wants you to input something. Once you have given an input. Your input will be saved under the name "VAR". You can change VAR to anything, but keep the dollar sign! Now, if you leave it as is but add text to the quotes INPUT "What's on your mind";VAR$ then exit edit mode, type run in the console and answer it, it will look like this: READY RUN What's on your mind? You OK Notice how we didn't add the question mark to the INPUT, but it showed up in the console? That's because, all INPUTS are questions originaly! So it automatically adds a question mark! But now, let's say you want their input to be a NUMBER! If so, you would change your code to this: INPUT "What's on your mind";VAR By removing that dollar sign it automatically knows you want the input to be a number. So let's change the words INPUT "Can I have a number";VAR Now, let's load up the console and type RUN and answer it: READY RUN Can I have a number? 2 OK But, if you type something that's not a number, you'll see this: READY RUN Can I have a number? NO ?Redo from start Can I have a number? So it will keep asking you input a number, until you ACTUALLY input a number! PRINT + INPUT Now let's combine our brand new skills to create a half decent program! If we continue from where we left off with the INPUT, but change the input back to words and change the question INPUT "What is your name";VAR$ Then add a PRINT command under it INPUT "What is your name';VAR$ PRINT VAR$ Now, what this will do is, once you input your name, it will print it back to you. Let's exit edit mode and type RUN in the console to see what it looks like: READY RUN What is your name? Carson Carson OK Now, what we can do is make it so once you input your name, it will print "Hello Carson" (With Carson being the person's name) Now, when doing this, do not try dong it like this: INPUT "What is your name";VAR$ PRINT "Hello VAR$" Because that would actually print "Hello VAR$" and we want it to print their name! So that would be achieved like this: INPUT "What is your name";VAR$ PRINT "Hello " + VAR$ Now, what this does it add their name after "Hello "! Now, why are we putting a space after "Hello"? Well, if we don't add that space it would print like this "HelloCarson". So the space will basically add a space between the two words. Now let's exit edit mode, and type RUN in the console! READY RUN What is your name? Carson Hello Carson OK And there you have it. You can get this program through the QR Code provided with this post! In the QR Code there is additional code, such as COLOR and BEEP commands. I will go over those in the next Tutorial! On to the next tutorial! Category:Resources Category:Tutorials